<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Change_role_model extends Model{
    function Change_role_model(){
        parent::Model();
    }

    function form($users){//tipe sama kyk res
        $this->load->helper('form');

        $data['nama'] = array(
            'name' => 'nameRole',
            'id' => 'nameRole',
        );
        //iterasi untuk semua user
        foreach ($users as $orang){
            $n = $orang->nama;
            $data['optionNama'][$n] = $n;
        }


        $data['selectr'] = array(
            'name' => 'selectRole',
            'id' => 'selectRole',
        );

        $data['optionrole'] = array(
            'manajer' => 'admin',
            'karyawan' => 'karyawan',
        );

        $data['submit'] = array(
            'name' => 'submitRole',
            'id' => 'submitRole',
            'value' => 'Ganti',
        );

        return $data;
    }

    function change(){
        $nama = $this->input->post('nameRole');
        $newrole = $this->input->post('selectRole');
        $this->load->library('db_pegawai');
        $this->db_pegawai->change_role($nama, $newrole);
    }
}
?>
